//
// Created by Semir on 2020/6/7.
//

#include <iostream>
#include <string>
#include <stack>

using namespace std;

string ReverseSentence(string str) {
    stack<string> S;
    string newStr = "";
    for (int i = 0; i < str.length(); i++) {
        if (str[i] == ' ' || str[i] == '\t') {
            if (newStr.length() > 0) {
                S.push(newStr);
                newStr = "";
            }
        } else {
            newStr += str[i];
        }
    }
    if (newStr.length() > 0) {
        S.push(newStr);
    }
    str = "";
    if (!S.empty()) {
        str += S.top();
        S.pop();
    }
    while (!S.empty()) {
        str += " ";
        str += S.top();
        S.pop();
    }
    return str;
}

int main() {
    string str = ReverseSentence(" ");
    cout << str << endl;
    return 0;
}